import request from '@/router/axios';
import {
    baseUrl,
    mockUrl,
} from '@/config/env';


export const getDic = type => request({
    url: `${baseUrl}/app/dict/${type}`,
    method: 'get',
});
export const checkUpdate = () => new Promise((resolve, reject) => {
    $.get(`${mockUrl}/api/v1/update`, (res) => {
        resolve({
            data: res,
        });
    });
});

export const getMenu = () => new Promise((resolve, reject) => {
    $.get(`${mockUrl}/api/v1/menu`, (res) => {
        resolve({
            data: res,
        });
    });
});
export const getHuodong = () => new Promise((resolve, reject) => {
    $.get(`${mockUrl}/api/v1/huodong`, (res) => {
        resolve({
            data: res,
        });
    });
});
export const getNews = page => request({
    url: `${baseUrl}/app/notificationInfo/index/page`,
    method: 'get',
    params: page,
});
export const getNewsObj = id => request({
    url: `${baseUrl}/app/notificationInfo/${id}`,
    method: 'get',
});

export const getCommunity = communityId => request({
    url: `${baseUrl}/app/bindOwner/getCommunityInfoById`,
    method: 'get',
    params: {
        communityId,
    },
});

export const getRun = () => new Promise((resolve, reject) => {
    $.get(`${mockUrl}/api/v1/run`, (res) => {
        resolve({
            data: res,
        });
    });
});
export const getMaintain = () => new Promise((resolve, reject) => {
    $.get(`${mockUrl}/api/v1/maintain`, (res) => {
        resolve({
            data: res,
        });
    });
});
export const sendCallLog = data => request({
    url: `${baseUrl}/entrance_guard/api/callLog`,
    method: 'post',
    headers: {
        loading: false,
    },
    data,
});

export const uploadImg = (relationId, content, type, imgType) => request({
    url: `${baseUrl}/app/upload`,
    method: 'post',
    data: {
        relationId,
        file: content,
        type,
        imgType,
    },
});

export const delImg = id => request({
    url: `${baseUrl}/app/repairRecord/deleteImg`,
    method: 'get',
    params: {
        id,
    },
});

export const getBanner = communityId => request({
    url: `${baseUrl}/app/showLbtApp`,
    method: 'post',
    data: `${communityId}`,
});

export const getLocalCode = (communityId, buildingId, unitId, type) => request({
    url: `${baseUrl}/entrance_guard/api/getQr`,
    method: 'get',
    headers: {
        loading: false,
    },
    params: {
        communityId,
        buildingId,
        unitId,
        type,
    },
});